package com.chief.sink.rocket;

import org.apache.commons.lang3.RandomUtils;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;
import com.alibaba.fastjson.JSON;
import java.nio.charset.StandardCharsets;
import java.util.Random;

public class RocketMqProducer {

    public static void main(String[] args) throws MQBrokerException, RemotingException, InterruptedException, MQClientException {
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer();
        defaultMQProducer.setNamesrvAddr("192.168.10.54:9876;192.168.10.55:9876");
        defaultMQProducer.setProducerGroup("aaaaaa");
        defaultMQProducer.setSendMsgTimeout(88888);
        defaultMQProducer.start();
        int i=0;
        while (true){
            i++;
            System.out.println(defaultMQProducer.send(new Message("inTest", ("3-"+i).getBytes(StandardCharsets.UTF_8))));
            Thread.sleep(10000);
        }
    }
}
